Introduction
There are a number of reasons you might need a clean installation of a database server on your Stack. Perhaps your application has begun to scale and you need to separate your database server from your application server. Maybe you want to try experiment with new PostgreSQL features or need to test out some unknown syntax. Either way, Stack Harbor has made it easy for you to deploy a simple PostgreSQL server in just a couple of minutes using our turnkey Stacks.
Accessing Your Application
Once your stack is built, we’ll need to SSH into the machine to gain access to privileged information such administrative password, which we recommend you use in place of the root account for security hardening purposes. If you don’t know how to SSH into your machine, we’ve written to a detailed tutorial to help you get started.
As soon as you SSH into your machine, you should see your access credentials echoed in the message of the day (MOTD). Consider taking note of these credentials somewhere secure and removing the message of the day. You can do so by running the rm -f /etc/motd command in your shell. To authenticate with the PostgreSQL client, we have to run the following command:
psql -U admin --password template1
This tells the PostgreSQL client that you wish to connect using the admin account and access the template1 database. You must always specify a database to use when authenticating with the PostgreSQL client. Since we’ve started from a fresh installation of Postgres, we have to use the ‘template1′ or ‘template0′ databases that come with Postgres in order to connect. Whenever you create a new database in PostgreSQL, you are actually building your database off of these two template databases. Run the following command to create your own database, specifying your own name where we’ve inserted ‘your_database_name’
CREATE DATABASE your_database_name WITH OWNER admin;
Now if you type \q into the shell and reauthenticate with the postgres client using the psql command, you’ll be able to use your new database at the end in place of template1 to connect to the database server.
Final Words
Congratulations! You’re all set up with a clean installation of PostgreSQL. From here on you can connect an external application to make database read/writes, test out SQL syntax and features, or install additional packages on top of your PostgreSQL module in order to build your very own Stack. Check out our Community Section for more information on how to secure your MariaDB server among other administrative and development tasks. From all of us at Stack Harbor, yarrr!